Skip to content

CLN/TYPE: window aggregation cleanups and typing #30137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 10, 2019

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added Clean Window rolling, ewma, expanding labels Dec 8, 2019
@mroeschke mroeschke added this to the 1.0 milestone Dec 8, 2019

is_monotonic_bounds = np.all(np.diff(start) > 0) and np.all(np.diff(end) > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a cdef function instead of copy?

@@ -412,7 +412,7 @@ def _get_roll_func(self, func_name: str) -> Callable:
)
return window_func

def _get_cython_func_type(self, func):
def _get_cython_func_type(self, func: str) -> Callable:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible to add subtypes to Callable typically very helpful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the arguments to the cython functions for rolling are still not entirely uniform so the argument list can't be typed consistently.


is_monotonic_bounds = np.all(np.diff(start) > 0) and np.all(np.diff(end) > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this call expensive? we might have something in _libs.algos that short-circuits this check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Was able to use is_monotonic in _libs.algos


is_monotonic_bounds = np.all(np.diff(start) > 0) and np.all(np.diff(end) > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a function


is_monotonic_bounds = is_monotonic(start, False)[0] and is_monotonic(end, False)[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth making this an inline helper function (not a big deal though)

@mroeschke
Copy link
Member Author

All green.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mroeschke mroeschke merged commit 52f5fdf into pandas-dev:master Dec 10, 2019
@mroeschke mroeschke deleted the indexer_cleanups branch December 10, 2019 01:50
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
* Move is_monotonic_bounds to the aggregation functions

* Remove single usage of _check_min in aggregations.pyx

* remove _check_min

* Add some typing

* fix condition

* Use is_monotonic from _lib.algos

* Add inline helper function
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
* Move is_monotonic_bounds to the aggregation functions

* Remove single usage of _check_min in aggregations.pyx

* remove _check_min

* Add some typing

* fix condition

* Use is_monotonic from _lib.algos

* Add inline helper function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants